<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="java.util.List"%>
<%@ page import="javax.jdo.PersistenceManager"%>
<%@ page import="com.google.appengine.api.users.User"%>
<%@ page import="com.google.appengine.api.users.UserService"%>
<%@ page import="com.google.appengine.api.users.UserServiceFactory"%>
<%@ page import="tt.Appuser"%>
<%@ page import="tt.Vuser"%>
<%@ page import="tt.PMF"%>
<%@ page import="com.googlecode.objectify.Query"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Tt</title>
</head>
<body>
<%
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user != null) {
    	Query<Appuser> users = Vuser.INSTANCE.getUsersz(user.getUserId());	
%>
<table>
	<tr>
		<th>Tipo</th>
		<th>Owner</th>
		<th>Name</th>
		<th>Pw</th>
	</tr>

	<% for (Appuser userr : users) {%>
	<tr>
		<td><%=userr.getTipo()%></td>
		<td><%=userr.getOwner()%></td>
		<td><%=userr.getName()%> - <%=userr.getApellido1()%> - <%=userr.getApellido2()%>
		</td>
		<td><%=userr.getPass()%></td>
		<td><a class="done" href="/remover?id=<%=userr.getId()%>">X</a>
		</td>
	</tr>
	<%}
%>
</table>
<hr>
<p>Add New User</p>
<form action="/newuser" method="post"><label>Nombre</label><input
	type="text" name="name" /><br>
<label>Apellido P.</label><input type="text" name="apellido1" /><br>
<label>Apellido M.</label><input type="text" name="apellido2" /><br>
<label>Tipo</label>
<select name="tipo">
  <option>Administrador</option>
  <option>Operador</option>
  <option>De Campo</option>
</select><br>
<label>Password</label><input type="password" name="pass" /><br>
<input type="submit" value="Crear" /></form>
<a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign
out</a>
<%
	}
    	else
    {
%>
<a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign
in</a>
<%
	}
%>
</body>
</html>